home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / languages / obrn-a_1.5_lib.lha / oberon-a / source1.lha / source / amiga / CDDevice.mod < prev    next >
Encoding:
Text File  |  1995-01-26  |  16.0 KB  |  373 lines

  1. (*************************************************************************
  2.  
  3.      $RCSfile: CDDevice.mod $
  4.   Description: Interface to cd.device
  5.  
  6.    Created by: fjc (Frank Copeland)
  7.     $Revision: 3.6 $
  8.       $Author: fjc $
  9.         $Date: 1995/01/26 02:39:55 $
  10.  
  11.   $VER: cd.h 1.11 (12.8.93)
  12.   Includes Release 40.15
  13.  
  14.   (C) Copyright 1992-1993 Commodore-Amiga, Inc.
  15.       All Rights Reserved
  16.  
  17.   Oberon-A Interface Copyright © 1994-1995, Frank Copeland.
  18.   This file is part of the Oberon-A Interface.
  19.   See Oberon-A.doc for conditions of use and distribution.
  20.  
  21. *************************************************************************)
  22.  
  23. <* STANDARD- *> <* INITIALISE- *> <* MAIN- *>
  24.  
  25. MODULE [2] CDDevice;
  26.  
  27. <*$ CaseChk-  IndexChk- LongVars+ NilChk-  *>
  28. <*$ RangeChk- StackChk- TypeChk-  OvflChk- *>
  29.  
  30. IMPORT e := Exec;
  31.  
  32. (**************************************************************************
  33.  *                                                                        *
  34.  *   CD Commands                                                          *
  35.  *                                                                        *
  36.  **************************************************************************)
  37.  
  38. CONST
  39.  
  40.   reset *        = 1;
  41.   read *         = 2;
  42.   write *        = 3;
  43.   update *       = 4;
  44.   clear *        = 5;
  45.   stop *         = 6;
  46.   start *        = 7;
  47.   flush *        = 8;
  48.   motor *        = 9;
  49.   seek *         = 10;
  50.   format *       = 11;
  51.   remove *       = 12;
  52.   changeNum *    = 13;
  53.   changeState *  = 14;
  54.   protStatus *   = 15;
  55.  
  56.   getDriveType * = 18;
  57.   getNumTracks * = 19;
  58.   addChangeInt * = 20;
  59.   remChangeInt * = 21;
  60.   getGeometry *  = 22;
  61.   eject *        = 23;
  62.  
  63.  
  64.   info *         = 32;
  65.   config *       = 33;
  66.   tocMSF *       = 34;
  67.   tocLSN *       = 35;
  68.  
  69.   readXL *       = 36;
  70.  
  71.   playTrack *    = 37;
  72.   playMSF *      = 38;
  73.   playLSN *      = 39;
  74.   pause *        = 40;
  75.   search *       = 41;
  76.  
  77.   qCodeMSF *     = 42;
  78.   qCodeLSN *     = 43;
  79.   attenuate *    = 44;
  80.  
  81.   addFrameInt *  = 45;
  82.   remFrameInt *  = 46;
  83.  
  84.  
  85. (**************************************************************************
  86.  *                                                                        *
  87.  *   Device Driver Error Codes                                            *
  88.  *                                                                        *
  89.  **************************************************************************)
  90.  
  91. CONST
  92.  
  93.   errOpenFail *       = -1;  (* device/unit failed to open   *)
  94.   errAborted *        = -2;  (* request terminated early             *)
  95.   errNoCmd *          = -3;  (* command not supported by device      *)
  96.   errBadLength *      = -4;  (* invalid length (IO_LENGTH/IO_OFFSET) *)
  97.   errBadAddress *     = -5;  (* invalid address (IO_DATA misaligned) *)
  98.   errUnitBusy *       = -6;  (* device opens ok, but unit is busy    *)
  99.   errSelfTest *       = -7;  (* hardware failed self-test            *)
  100.  
  101.   errNotSpecified *   = 20;  (* general catchall                     *)
  102.   errNoSecHdr *       = 21;  (* couldn't even find a sector          *)
  103.   errBadSecPreamble * = 22;  (* sector looked wrong                  *)
  104.   errBadSecID *       = 23;  (* ditto                                *)
  105.   errBadHdrSum *      = 24;  (* header had incorrect checksum        *)
  106.   errBadSecSum *      = 25;  (* data had incorrect checksum          *)
  107.   errTooFewSecs *     = 26;  (* couldn't find enough sectors         *)
  108.   errBadSecHdr *      = 27;  (* another "sector looked wrong"        *)
  109.   errWriteProt *      = 28;  (* can't write to a protected disk      *)
  110.   errNoDisk *         = 29;  (* no disk in the drive                 *)
  111.   errSeekError *      = 30;  (* couldn't find track 0                *)
  112.   errNoMem *          = 31;  (* ran out of memory                    *)
  113.   errBadUnitNum *     = 32;  (* asked for a unit > NUMUNITS          *)
  114.   errBadDriveType *   = 33;  (* not a drive cd.device understands    *)
  115.   errDriveInUse *     = 34;  (* someone else allocated the drive     *)
  116.   errPostReset *      = 35;  (* user hit reset; awaiting doom        *)
  117.   errBadDataType *    = 36;  (* data on disk is wrong type   *)
  118.   errInvalidState *   = 37;  (* invalid cmd under current conditions *)
  119.  
  120.   errPhase *          = 42;  (* illegal or unexpected SCSI phase     *)
  121.   errNoBoard *        = 50;  (* open failed for non-existant board   *)
  122.  
  123.  
  124.  
  125. (**************************************************************************
  126.  *                                                                        *
  127.  * Configuration                                                          *
  128.  *                                                                        *
  129.  *       The drive is configured by TagList items defined as follows:     *
  130.  *                                                                        *
  131.  **************************************************************************)
  132.  
  133. CONST
  134.  
  135.   playSpeed *   = 00001H;
  136.   readSpeed *   = 00002H;
  137.   readXLSpeed * = 00003H;
  138.   sectorSize *  = 00004H;
  139.   xlECC *       = 00005H;
  140.   ejectReset *  = 00006H;
  141.  
  142.  
  143. (**************************************************************************
  144.  *                                                                        *
  145.  * Information                                                            *
  146.  *                                                                        *
  147.  *      Information/Status structure describes current speed settings     *
  148.  *      for read and play commands, sector size, audio attenuation        *
  149.  *      precision, and drive status.                                      *
  150.  *                                                                        *
  151.  **************************************************************************)
  152.  
  153. TYPE
  154.  
  155.   CDInfoPtr * = POINTER TO CDInfo;
  156.   CDInfo  * = RECORD        (*                                Default       *)
  157.     playSpeed *      : e.UWORD; (* Audio play speed       (75)              *)
  158.     readSpeed *      : e.UWORD; (* Data-rate of CD_READ command   (Max)     *)
  159.     readXLSpeed *    : e.UWORD; (* Data-rate of CD_READXL command (75)      *)
  160.     sectorSize *     : e.UWORD; (* Number of bytes per sector     (2048)    *)
  161.     xlECC *          : e.UWORD; (* CDXL ECC enabled/disabled                *)
  162.     ejectReset *     : e.UWORD; (* Reset on eject enabled/disabled          *)
  163.     reserved1 *      : ARRAY 4 OF e.UWORD; (* Reserved for future expansion *)
  164.     maxSpeed *       : e.UWORD; (* Maximum speed drive can handle (75, 150) *)
  165.     audioPrecision * : e.UWORD; (* 0 = no attenuator, 1 = mute only,        *)
  166.                                 (* other = (# levels - 1)                   *)
  167.     status *         : e.UWORD; (* See flags below                          *)
  168.     reserved2 *      : ARRAY 4 OF e.UWORD; (* Reserved for future expansion *)
  169.   END;
  170.  
  171. CONST
  172.  
  173. (* Flags for Status *)
  174.  
  175.   stsbClosed *    = 0;  (* Drive door is closed                        *)
  176.   stsbDisk *      = 1;  (* A disk has been detected                    *)
  177.   stsbSpin *      = 2;  (* Disk is spinning (motor is on)              *)
  178.   stsbTOC *       = 3;  (* Table of contents read.  Disk is valid.     *)
  179.   stsbCDRom *     = 4;  (* Track 1 contains CD-ROM data                *)
  180.   stsbPlaying *   = 5;  (* Audio is playing                            *)
  181.   stsbPaused *    = 6;  (* Pause mode (pauses on play command)         *)
  182.   stsbSearch *    = 7;  (* Search mode (Fast Forward/Fast Reverse)     *)
  183.   stsbDirection * = 8;  (* Search direction (0 = Forward, 1 = Reverse) *)
  184.  
  185. (* Modes for CD_SEARCH *)
  186.  
  187.   normal *   = 0;  (* Normal play at current play speed    *)
  188.   fFwd *     = 1;  (* Fast forward play (skip-play forward)*)
  189.   fRev *     = 2;  (* Fast reverse play (skip-play reverse)*)
  190.  
  191.  
  192. (**************************************************************************
  193.  *                                                                        *
  194.  * Position Information                                                   *
  195.  *                                                                        *
  196.  *      Position information can be described in two forms: MSF and LSN   *
  197.  *      form.  MSF (Minutes, Seconds, Frames) form is a time encoding.    *
  198.  *      LSN (Logical Sector Number) form is frame (sector) count.         *
  199.  *      The desired form is selected using the io_Flags field of the      *
  200.  *      IOStdReq structure.  The flags and the union are described        *
  201.  *      below.                                                            *
  202.  *                                                                        *
  203.  **************************************************************************)
  204.  
  205. TYPE
  206.  
  207.   RMSFPtr * = POINTER TO RMSF;
  208.   RMSF  * = RECORD
  209.     reserved * : SHORTINT;  (* Reserved (always zero) *)
  210.     minute *   : SHORTINT;  (* Minutes (0-72ish)      *)
  211.     second *   : SHORTINT;  (* Seconds (0-59)         *)
  212.     frame *    : SHORTINT;  (* Frame   (0-74)         *)
  213.   END;
  214.  
  215.   RLSNPtr * = POINTER TO RLSN;
  216.   RLSN  * = RECORD
  217.     lsn * : e.ULONG;       (* Logical Sector Number  *)
  218.   END;
  219.  
  220.  
  221. (**************************************************************************
  222.  *                                                                        *
  223.  * CD Transfer Lists                                                      *
  224.  *                                                                        *
  225.  *      A CDXL node is a double link node; however only single linkage    *
  226.  *      is used by the device driver.  If you wish to construct a         *
  227.  *      transfer list manually, it is only neccessary to define the       *
  228.  *      mln_Succ pointer of the MinNode.  You may also use the Exec       *
  229.  *      list functions by defining a List or MinList structure and by     *
  230.  *      using the AddHead/AddTail functions to create the list.  This     *
  231.  *      will create a double-linked list.  Although a double-linked       *
  232.  *      list is not required by the device driver, you may wish use it    *
  233.  *      for your own purposes.  Don't forget to initialize the            *
  234.  *      the List/MinList before using it!                                 *
  235.  *                                                                        *
  236.  **************************************************************************)
  237.  
  238. TYPE
  239.  
  240.   CDXLPtr * = POINTER TO CDXL;
  241.   CDXL  * = RECORD (e.MinNodeBase)
  242.     node *    : e.MinNode;     (* double linkage                  *)
  243.     buffer *  : e.APTR;        (* data destination (word aligned) *)
  244.     length *  : LONGINT;       (* must be even # bytes            *)
  245.     actual *  : LONGINT;       (* bytes transferred               *)
  246.     intData * : e.APTR;        (* interrupt server data segment   *)
  247.     IntCode * : e.PROC;        (* interrupt server code entry     *)
  248.   END;
  249.  
  250.  
  251. (**************************************************************************
  252.  *                                                                        *
  253.  * CD Table of Contents                                                   *
  254.  *                                                                        *
  255.  *      The CD_TOC command returns an array of CDTOC entries.             *
  256.  *      Entry zero contains summary information describing how many       *
  257.  *      tracks the disk has and the play-time of the disk.                *
  258.  *      Entries 1 through N (N = Number of tracks on disk) contain        *
  259.  *      information about the track.                                      *
  260.  *                                                                        *
  261.  **************************************************************************)
  262.  
  263. TYPE
  264.  
  265.   TOCSummary  * = RECORD END;
  266.   TOCSummaryPtr *= POINTER TO TOCSummary;
  267.  
  268.   TOCSummaryMSFPtr * = POINTER TO TOCSummaryMSF;
  269.   TOCSummaryMSF  * = RECORD (TOCSummary)
  270.     firstTrack * : SHORTINT; (* First track on disk (always 1)            *)
  271.     lastTrack *  : SHORTINT; (* Last track on disk                        *)
  272.     leadOut *    : RMSF;     (* Beginning of lead-out track (end of disk) *)
  273.   END;
  274.  
  275.   TOCSummaryLSNPtr * = POINTER TO TOCSummaryLSN;
  276.   TOCSummaryLSN  * = RECORD (TOCSummary)
  277.     firstTrack * : SHORTINT; (* First track on disk (always 1)            *)
  278.     lastTrack *  : SHORTINT; (* Last track on disk                        *)
  279.     leadOut *    : RLSN;     (* Beginning of lead-out track (end of disk) *)
  280.   END;
  281.  
  282.   TOCEntry  * = RECORD END;
  283.   TOCEntryPtr *= POINTER TO TOCEntry;
  284.  
  285.   TOCEntryMSFPtr * = POINTER TO TOCEntryMSF;
  286.   TOCEntryMSF  * = RECORD (TOCEntry)
  287.     ctlAdr *   : SHORTINT;     (* Q-Code info                  *)
  288.     track *    : SHORTINT;     (* Track number                 *)
  289.     position * : RMSF;         (* Start position of this track *)
  290.   END;
  291.  
  292.   TOCEntryLSNPtr * = POINTER TO TOCEntryLSN;
  293.   TOCEntryLSN  * = RECORD (TOCEntry)
  294.     ctlAdr *   : SHORTINT;     (* Q-Code info                  *)
  295.     track *    : SHORTINT;     (* Track number                 *)
  296.     position * : RLSN;         (* Start position of this track *)
  297.   END;
  298.  
  299.   CDTOC  * = RECORD END;
  300.   CDTOCPtr *= POINTER TO CDTOC;
  301.  
  302.   CDTOCMSFPtr * = POINTER TO CDTOCMSF;
  303.   CDTOCMSF  * = RECORD (CDTOC)
  304.     summary * : TOCSummaryMSF; (* First entry (0) is summary information *)
  305.     entry *   : ARRAY 256 OF TOCEntryMSF; (* Entries 1-N are track entries          *)
  306.   END;
  307.  
  308.   CDTOCLSNPtr * = POINTER TO CDTOCLSN;
  309.   CDTOCLSN  * = RECORD (CDTOC)
  310.     summary * : TOCSummaryLSN; (* First entry (0) is summary information *)
  311.     entry *   : ARRAY 256 OF TOCEntryLSN; (* Entries 1-N are track entries          *)
  312.   END;
  313.  
  314.  
  315. (**************************************************************************
  316.  *                                                                        *
  317.  * Q-Code Packets                                                         *
  318.  *                                                                        *
  319.  *      Q-Code packets are only returned when audio is playing.           *
  320.  *      Currently, only position packets are returned (ADR_POSITION)      *
  321.  *      The other ADR_ types are almost never encoded on the disk         *
  322.  *      and are of little use anyway.  To avoid making the QCode          *
  323.  *      structure a union, these other ADR_ structures are not defined.   *
  324.  *                                                                        *
  325.  **************************************************************************)
  326.  
  327. TYPE
  328.  
  329.   QCodeMSFPtr * = POINTER TO QCodeMSF;
  330.   QCodeMSF  * = RECORD
  331.     ctlAdr *        : SHORTINT; (* Data type / QCode type           *)
  332.     track *         : SHORTINT; (* Track number                     *)
  333.     index *         : SHORTINT; (* Track subindex number            *)
  334.     zero *          : SHORTINT; (* The "Zero" byte of Q-Code packet *)
  335.     trackPosition * : RMSF;     (* Position from start of track     *)
  336.     diskPosition *  : RMSF;     (* Position from start of disk      *)
  337.   END;
  338.  
  339.   QCodeLSNPtr * = POINTER TO QCodeLSN;
  340.   QCodeLSN  * = RECORD
  341.     ctlAdr *        : SHORTINT; (* Data type / QCode type           *)
  342.     track *         : SHORTINT; (* Track number                     *)
  343.     index *         : SHORTINT; (* Track subindex number            *)
  344.     zero *          : SHORTINT; (* The "Zero" byte of Q-Code packet *)
  345.     trackPosition * : RLSN;     (* Position from start of track     *)
  346.     diskPosition *  : RLSN;     (* Position from start of disk      *)
  347.   END;
  348.  
  349. CONST
  350.  
  351.   ctlAdrCtlMask * = 0F0H;  (* Control field *)
  352.  
  353.   ctlCtlMask *    = 0D0H;  (* To be ANDed with CtlAdr before compared  *)
  354.  
  355.   ctl2Aud *       = 000H;  (* 2 audio channels without preemphasis     *)
  356.   ctl2AudEmph *   = 010H;  (* 2 audio channels with preemphasis        *)
  357.   ctl4Aud *       = 080H;  (* 4 audio channels without preemphasis     *)
  358.   ctl4AudEmph *   = 090H;  (* 4 audio channels with preemphasis        *)
  359.   ctlData *       = 040H;  (* CD-ROM Data                              *)
  360.  
  361.   ctlCopyMask *   = 020H;  (* To be ANDed with CtlAdr before compared  *)
  362.  
  363.   ctlCopy *       = 020H;  (* When true, this audio/data can be copied *)
  364.  
  365.   ctlAdrAdrMask * = 00FH;  (* Address field                            *)
  366.  
  367.   adrPosition *   = 001H;  (* Q-Code is position information   *)
  368.   adrUPC *        = 002H;  (* Q-Code is UPC information (not used)     *)
  369.   adrISRC *       = 003H;  (* Q-Code is ISRC (not used)                *)
  370.   adrHybrid *     = 005H;  (* This disk is a hybrid disk               *)
  371.  
  372. END CDDevice.
  373.